﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_MailFolderClear]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_MailFolderClear];
GO
CREATE PROCEDURE [dbo].[sproc_MailFolderClear]
(
    @FolderType int ,
    @Username nvarchar(30)
)
AS
  
   DECLARE @Sql NVARCHAR(4000)    
    SET @Sql =  "DELETE FROM  TabMailList WHERE  MailFolderType="+ CONVERT(nvarchar(6), @FolderType) +" AND (MailReceiver='"+@Username+"' or MailSender='"+@Username+"')"
   print @Sql
   EXECUTE ( @Sql)